Using Script Properties
To see how script properties work, try running the following script, which contains a script property calledtheCount
.
property theCount : 0 set theCount to theCount+1 display dialog "The value of theCount is: " & theCount ÿ as stringThe first time you run the script, the value oftheCount
is set to 0. The Set command adds one totheCount
, and the Display Dialog command displays the value oftheCount
, which is 1.Now run the script again. The Set command adds 1 to the value of
theCount
(which is still one because it has not been reset), and the Display Dialog command reports a value of 2. If you run the script a third time, the value oftheCount
is 3, and so on.Now save the script as a compiled script. Close the script, and then open and run it without making any changes. The value of
theCount
is one more than it was before you closed the script.Finally, recompile the script. (You can do this by making an insignificant change, such as adding a space at the end of a line, and clicking the Check Syntax button.) The value of
theCount
is set to the initial value in the property definition. The Display Dialog command reports a value of 1.